function transImage(inpath, outpath, q)
    if nargin < 3
        q = 100;
    end
    flist = [dir([inpath,'/*.tif']);dir([inpath,'/*.bmp'])];
    fnum = size(flist,1);
    for i = 1:fnum
        if (flist(i).isdir == 0) && (flist(i).bytes > 0)
            name = flist(i).name;
            iname = [inpath,'/',name];
            oname = [outpath,'/',name(1,1:size(name,2)-3),'jpg'];
            fprintf(1,'%s->%s',iname,oname);
            img = imread(iname);
            imwrite(img, oname, 'quality',q);
            fprintf(1,'\tOK\n');
        end
    end
end
